<?php
/**
 * @version		0.2.0 joomla zmluvy $
 * @package		com_zjmluvy
 * @copyright	Copyright © 2011 - All rights reserved.
 * @license		GNU/GPL
 * @author    AdrianKo		
 * @website   http://code.google.com/p/joomla-zmluvy
 *
 *
 *1.3.2012
 */

// no direct access
defined('_JEXEC') or die('Restricted access');

JHTML::_('behavior.tooltip'); 
	JToolBarHelper::title( JText::_( '&nbsp;&nbsp;&nbsp;'.JText::_( 'title_FAKTURY_EDIT' ) ), 'faktury' );
  
  //*** podmienky pre zobrazenie ikony pre mazanie dokumentov
  if (!empty($this->item->file)) {
    JToolBarHelper::customX( 'deletefile', 'delete','',JText::_( 'fa_EDIT_SUBOR_ZMAZ_SKEN' ), false);
  }
  if (!empty($this->item->file2)) {
    JToolBarHelper::customX( 'deletefile2', 'delete','',JText::_( 'fa_EDIT_SUBOR_ZMAZ_TEXT'), false);
  }
  JToolBarHelper::save();
	JToolBarHelper::apply();
	if (JRequest::getVar('edit')) {
		JToolBarHelper::cancel( 'cancel', 'Close' );
	} else {
		JToolBarHelper::cancel();
	}
//	JToolBarHelper::help( 'screen.users' );  
  $editor =& JFactory::getEditor();
  
  //*** zameni hodnotu v datume z 0000-00-00 za vlastne v confug.xml
  $platnost = 0;
  if ($this->item->publish_down == '0000-00-00' || $this->item->publish_down == 0) {
    $platnost = 1;
    $this->item->publish_down = $this->nastavenie->datum_text;
  }
  if ($this->item->publish_up == '0000-00-00' || $this->item->publish_up == 0) {
    $platnost = 1;
    $this->item->publish_up = $this->nastavenie->datum_text;
  } 
  if ($this->item->datUhrady == '0000-00-00' || $this->item->datUhrady == 0) {
    $platnost = 1;
    $this->item->datUhrady = $this->nastavenie->datum_text;
  }
  if ($this->item->datZver == '0000-00-00' || $this->item->datZver == 0) {
    $platnost = 1;
    $this->item->datZver = $this->nastavenie->datum_text;
  }    
   
 ?>
<form action="index.php" method="post" name="adminForm" enctype="multipart/form-data">
  <div class="col width-60">
    <fieldset class="adminform">
      <legend>
        <?php echo JText::_( 'fa_EDIT_BLOK_FAK' ); ?>
      </legend>
      
      <table class="admintable">
        <tr> 
          <td class="key"> 
            <label for="faktura">
              <?php echo JText::_( 'fa_EDIT_CISLO_FAK' ); ?>:
            </label>
          </td>
          <td> 
            <input id="faktura" class="text_area" name="faktura" title="<?php echo JText::_( 'fa_EDIT_FAK_CISLO'  ); ?>" value="<?php echo $this->item->faktura; ?>" size="30" maxlength="50" />
          </td>
        </tr>
        
        <?php if($this->nastavenie->fak_int_cislo) : ?>
        <tr> 
          <td class="key"> 
            <label for="intCislo">
              <?php echo JText::_( 'fa_EDIT_CISLO_FAK_INTER' ); ?>:
            </label>
          </td>
          <td> 
            <input id="intCislo" class="text_area" name="intCislo" title="<?php echo JText::_( 'Interé číslo' ); ?>" value="<?php echo $this->item->intCislo; ?>" size="30" maxlength="50" />
          </td>
        </tr>
        
        <?php endif ?>
        <tr> 
          <td class="key"> 
            <label for="dodavatel"> 
              <?php if (($this->item->dodavatel) != 0) { ?>                            
              <?php echo "<a title='".JText::_( 'VYTVOR_PARTNERA' )."' href='index.php?option=com_jzmluvy&view=upravapartner&task=edit&id[]=".$this->item->dodavatel."'>".JText::_( 'fa_EDIT_PARTNER' )."</a>:"; ?>
              <?php } else { ?> 
              <?php echo JText::_( 'fa_EDIT_PARTNER' ).":"; ?>
              <?php } ?>
            </label>
          </td> 
          <td>
            <?php echo $this->lists['dod']; ?>
            <?php echo jzmluvyHelper::obrazok('povinne-16.png','',JText::_( 'fa_POVINNE' )) ?>      
            <?php echo "<a title='".JText::_( '' )."' href='index.php?option=com_jzmluvy&view=upravapartner&task=edit&id[]=0'>".JText::_( 'fa_EDIT_NOVY' )."</a>" ?>
          </td>
        </tr>
        
        <tr> 
          <td class="key"> 
            <label for="title">
              <?php echo JText::_( 'fa_EDIT_PREDMET' ); ?>:
            </label>
          </td>
          <td> 
            <textarea id="title" class="text_area" name="title" cols="50" rows="3" title="<?php echo JText::_( '' ); ?>"><?php echo $this->item->title; ?></textarea>
            <?php echo jzmluvyHelper::obrazok('povinne-16.png','',JText::_( 'fa_POVINNE' )) ?>
          </td>
        </tr>

        <tr> 
          <td class="key"> 
            <label for="suma">
              <?php echo JText::_( 'fa_EDIT_SUMA' ); ?> <?php if($this->nastavenie->dph) { echo JText::_( 'OBJ_SDPH' ); } else { echo JText::_( 'OBJ_BEZDPH' ); } ?>:
            </label>
          </td>
          <td> 
            <input id="suma" class="text_area" name="suma" title="<?php echo JText::_( 'fa_SUMA_INFO' ); ?>" value="<?php echo jzmluvyHelper::format_number($this->item->suma,',',''); ?>" size="30" maxlength="50" /> 
            <input id="mena" class="text_area" name="mena" title="<?php echo JText::_( 'fa_MENA_INFO' ); ?>" value="<?php echo $this->item->mena; ?>" size="10" maxlength="10" /> 
            <?php echo jzmluvyHelper::obrazok('povinne-16.png','',JText::_( 'fa_POVINNE' )) ?>
          </td>
        </tr>

        <?php if($this->nastavenie->crz) : ?>
        <tr> 
          <td class="key"> 
            <label title="<?php echo JText::_( 'ZM_IDENT_ZMLUVY_RZ_I' ); ?>">
              <?php echo JText::_( 'zm_ident_zmluvy_rz' ).":"; ?>
            </label>
          </td> 
          <td> 
            <input id="jedcislo" class="text_area" name="jedcislo" title="<?php echo JText::_( 'zm_ident_zmluvy_rz_zmluva' ); ?>" value="<?php echo $this->item->jedcislo; ?>" size="10" maxlength="50" />
            http://<input id="vlastni1" class="text_area" name="vlastni1" title="<?php echo JText::_( 'ZM_IDENT_ZMLUVY_RZ_LINK');   ?>" value="<?php echo $this->item->vlastni1; ?>" size="40" maxlength="80" />
          </td>
        </tr>
        <?php endif; ?>                  
        
        <tr> 
          <td class="key"> 
            <label>
              <?php if ($this->item->typ) : ?>                            
              <?php echo "<a title='".JText::_( '' )."' href='index.php?option=com_jzmluvy&view=upravazmluvy&task=edit&id[]=".$this->item->typ."'>".JText::_( 'zm_ident_zmluvy' )."</a>:"; ?>
              <?php else : ?>
              <?php echo JText::_( 'zm_ident_zmluvy' ).":"; ?>
              <?php endif; ?>
            </label>
          </td> 
          <td> 
            <?php echo $this->lists['zmluva']; ?><br />
          </td>
        </tr>

        <tr> 
          <td class="key"> 
            <label> 
              <?php if (($this->item->sposob) != 0) { ?>                            
              <?php echo "<a title='".JText::_( '' )."' href='index.php?option=com_jzmluvy&view=upravaobjednavky&task=edit&id[]=".$this->item->sposob."'>".JText::_( 'zm_ident_objednavky' )."</a>:"; } else {?>
              <?php echo JText::_( 'zm_ident_objednavky' ).":"; } ?>
            </label>
          </td> 
          <td> 
            <?php echo $this->lists['objednavka']; ?>
          </td>
        </tr>       
      </table>
      
    </fieldset>
    
    <fieldset class="adminform">
      <legend>
        <?php echo JText::_( 'fa_EDIT_BLOK_DAT' ); ?>
      </legend>
      <table class="admintable">
        <tr> 
          <td class="key"> 
            <label for="publish_up">
              <?php echo JText::_( 'fa_EDIT_DAT_DORUCENIA' ); ?>:
            </label>
          </td>
          <td>
            <?php echo JHTML::_('calendar', jzmluvyHelper::datdmy($this->item->publish_up), "publish_up", "publish_up", '%d.%m.%Y'); ?>
            <?php echo jzmluvyHelper::obrazok('povinne-16.png','',JText::_( 'fa_POVINNE' )) ?>
          </td>
        </tr>
        
        <tr>
          <td class="key"> 
            <label for="datZver">
              <?php echo JText::_( 'fa_EDIT_DAT_ZVEREJNENIE' ); ?>:
            </label>
          </td>
          <td>
            <?php echo JHTML::_('calendar', jzmluvyHelper::datdmy($this->item->datZver), "datZver", "datZver", '%d.%m.%Y'); ?>
            <?php echo jzmluvyHelper::obrazok('povinne-16.png','',JText::_( 'fa_POVINNE' )) ?>
          </td>
        </tr>
        
        <?php if($this->nastavenie->fak_dat_platnosti) : ?>
        <tr>
          <td class="key"> 
            <label for="publish_down">
              <?php echo JText::_( 'fa_EDIT_DAT_SPLATNOST' ); ?>:
            </label>
          </td>
          <td>
            <?php echo JHTML::_('calendar', jzmluvyHelper::datdmy($this->item->publish_down), "publish_down", "publish_down", '%d.%m.%Y'); ?> 
          </td>
        </tr>
        <?php endif; ?>
        
        <?php if($this->nastavenie->fak_dat_uhrady) : ?>
        <tr>
          <td class="key"> 
            <label for="datUhrady">
              <?php echo JText::_( 'fa_EDIT_DAT_UHRADA' ); ?>:
            </label>
          </td>
          <td>
            <?php echo JHTML::_('calendar', jzmluvyHelper::datdmy($this->item->datUhrady), "datUhrady", "datUhrady", '%d.%m.%Y'); ?>
            <?php // echo jzmluvyHelper::obrazok('povinne-16.png','',JText::_( 'fa_POVINNE' )) ?>
          </td>
        </tr>
        <?php endif; ?>
      </table>
    </fieldset>
    
    <fieldset class="adminform">
      <legend>
         <?php if($this->nastavenie->subory) { echo JText::_( 'FA_DOK' ); } else { echo JText::_( 'FA_DOK_BEZ' ); } ?>
      </legend>
      <table class="admintable">
      
      <?php  if($this->nastavenie->subory) : ?>  
        <tr> 
          <td class="key"> 
            <label for="soubor">
              <?php echo JText::_( 'fa_EDIT_SUBOR_SKEN' ); ?>:
            </label>
          </td>
          <td>
            <?php if (empty($this->item->file)) { ?> 
              <input type="file" id="soubor" name="soubor" style="width: 300px;" />
            <?php } else { ?>
            <?php echo jzmluvyHelper::ikona ($this->item->extension,$this->item->file).' '.$this->item->file; ?>
            <?php echo '<input type="hidden" name="soubor" id="soubor" value="'.$this->item->file.'" />'; ?>
            <?php } ?>
          </td>					 
        </tr>
        <tr> 
          <td class="key"> 
            <label for="soubor2">
              <?php echo JText::_( 'fa_EDIT_SUBOR_TXT' ); ?>:
            </label>
          </td>
          <td>
            <?php if (empty($this->item->file2)) { ?> 
              <input type="file" name="soubor2" id="soubor2" style="width: 300px;" />
            <?php } else { ?>
            <?php echo jzmluvyHelper::ikona ($this->item->extension2,$this->item->file2).' '.$this->item->file2; ?>
            <?php echo '<input type="hidden" name="soubor2" id="soubor2" value="'.$this->item->file2.'" />'; ?>
            <?php } ?>
          </td>					 
        </tr>
      <?php endif; ?>
           	
        <tr> 
          <td class="key"> 
            <label for="fulltext">
              <?php echo JText::_( 'fa_EDIT_POZNAMKA' ); ?>:
            </label>
          </td>
          <td> 
            <textarea id="fulltext" class="text_area" name="fulltext" cols="55" rows="3" title="<?php echo JText::_( 'Poznamka' ); ?>"><?php echo $this->item->fulltext; ?></textarea>
          </td>
        </tr>
      </table>
    </fieldset>
  </div>
    
  <?php //*** blok na pravo info a statistika ?> 
  <?php if($this->item->id != '') { ?>
  <div style="float:right;" class="col width-30">
    <fieldset class="adminform">
      <legend>
        <?php echo JText::_( 'fa_EDIT_BLOK_STAT' ); ?>
      </legend>
      <table class="admintable">
        <tr> 
          <td class="key"> 
            <label>
              <?php echo JText::_( 'fa_EDIT_STAT_VYTVORIL' ); ?>:
            </label>
          </td>
          <td>
            <?php echo jzmluvyHelper::uzivatel($this->item->id)->vytvoril;?>
          </td>
        </tr>
        
        <tr> 
          <td class="key"> 
            <label>
              <?php echo JText::_( 'fa_EDIT_STAT_DAT_VYTVORENIA' ); ?>:
            </label>
          </td>
          <td>
            <?php echo $this->item->created; ?>
          </td>
        </tr>
        
        <?php if($this->item->modified != 0 ) { ?>
        <tr> 
          <td class="key"> 
            <label>
              <?php echo JText::_( 'fa_EDIT_STAT_UPRAVIL' ); ?>:
            </label>
          </td>
          <td>
            <?php echo jzmluvyHelper::uzivatel($this->item->id)->zmenil;?>
          </td>
        </tr>
        <tr> 
          <td class="key"> 
            <label>
              <?php echo JText::_( 'fa_EDIT_STAT_DAT_UPRAVY' ); ?>:
            </label>
          </td>
          <td>
            <?php echo $this->item->modified; ?>
          </td>
        </tr>
        <?php } ?>
        
        <tr> 
          <td class="key"> 
            <label for="hits_detail">
              <?php echo JText::_( 'fa_EDIT_STAT_POCET_ZOBRAZENI' ); ?>:
            </label>
          </td>
          <td>
            <input id="hits_detail" class="text_area" name="hits_detail" title="<?php echo JText::_( 'fa_POCET_ZOBRAZENI_INFO' ); ?>" value="<?php echo $this->item->hits_detail; ?>" size="10" maxlength="50" />&nbsp;
            <?php echo JText::_( 'fa_EDIT_STAT_KRAT' ); ?>
          </td>
        </tr>
        
        <?php if($this->item->hits != 0 || $this->item->filename != '') { ?>
        <tr> 
          <td class="key"> 
            <label for="hits">
              <?php echo JText::_( 'fa_EDIT_STAT_STIAH_SCAN' ); ?>:
            </label>
          </td>
          <td> 
            <input id="hits" class="text_area" name="hits" title="<?php echo JText::_( 'fa_STIAH_SCAN_INFO' ); ?>" value="<?php echo $this->item->hits; ?>" size="10" maxlength="50" />&nbsp;
            <?php echo JText::_( 'fa_EDIT_STAT_KRAT' ); ?>
          </td>
        </tr>
        <?php } ?>
        
        <?php if($this->item->hits2 != 0 || $this->item->filename2 != '') { ?>
        <tr> 
          <td class="key"> 
            <label for="hits2">
              <?php echo JText::_( 'fa_EDIT_STAT_STIAH_TEXT' ); ?>:
            </label>
          </td>
          <td>
            <input id="hits2" class="text_area" name="hits2" title="<?php echo JText::_( 'fa_STIAH_TEXT_INFO' ); ?>" value="<?php echo $this->item->hits2; ?>" size="10" maxlength="50" />&nbsp;
            <?php echo JText::_( 'fa_EDIT_STAT_KRAT' ); ?>
          </td>
        </tr>
        <?php } ?>
      </table>
    </fieldset>
  </div>
  <?php } ?>
  <div class="clr">
  </div> 
  <input type="hidden" name="option" value="com_jzmluvy" /> 
  <input type="hidden" name="controller" value="upravafaktury" /> 
  <input type="hidden" name="id" value="<?php echo $this->item->id; ?>" /> 
  <input type="hidden" name="task" value="edit" /> 
  <input type="hidden" name="redirect" value="<?php //echo $redirect; ?>" />
  <?php echo JHTML::_( 'form.token' ); ?>
</form>